package com.controller;

import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.entity.Message;
import com.service.UserService;


@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userS;
	@RequestMapping("/login")
	private @ResponseBody Message login(@RequestParam Map map,HttpSession session){
		Map map2 = userS.login(map);
		Message message = null;
		if(map2!=null && !map2.isEmpty()){
			message = new Message( "登陆成功",true);
			session.setAttribute("user",map2);
		}else{
			message = new Message("登陆失败",false);
		}
		return message;
	}
	@RequestMapping("/zhuce")
	private @ResponseBody Message zhuce(@RequestParam Map map){
		int a = userS.zhuce(map);
		Message message = null;
		if(a>0){
			message = new Message( "注册成功",true);
		}else{
			message = new Message("注册失败",false);
		}
		return message;
	}
}
